(function() {
    // 实例化对象
    let myChart = echarts.init(document.querySelector(".recent .data-view"));
    // 指定配置和数据
    let option = {
        color: ["#2f89cf"],
        //color: "#07e7c2",

        tooltip: {
            trigger: "axis",
            axisPointer: {
                // 坐标轴指示器，坐标轴触发有效
                type: "shadow" // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        grid: {
            left: "0%",
            top: "10px",
            right: "0%",
            bottom: "4%",
            containLabel: true
        },
        //刻度标签属性
        xAxis: [ //
            {
                type: "category",
                data: ["111", "3423", "国贸343", "34", "生化", "机械", "职教", "a", "a", "a", "a"],
                axisTick: {
                    alignWithLabel: true
                },
                axisLabel: {
                    color: "rgba(255,255,255,.6)",
                    fontSize: "12",
                    interval: 0
                },
                axisLine: {
                    show: false
                }

            }
        ],
        yAxis: [ //
            {
                type: "value",
                axisLabel: {
                    color: "rgba(255,255,255,.6)",
                    fontSize: "12"
                },
                axisLine: {
                    lineStyle: {
                        color: "rgba(255,255,255,.1)",
                    }
                },
                // y 轴分隔线样式
                splitLine: {
                    lineStyle: {
                        color: "rgba(255,255,255,.1)"
                    }
                }


            }
        ],

        series: [{
            name: "累计确诊人数: ",
            type: "bar",
            barWidth: "35%",
            data: [10, 52, 200, 334, 390, 330, 220, 0, 0, 0, 0],
            //修改圆角
            itemStyle: {
                barBorderRadius: 4,
            }


        }]
    };



    fetch("data/gesheng.json").then(data1 => {
        return data1.json();
    }).then(data1 => {

        console.log(data1)
        for (i = 0; i < 11; i++) {
            option.xAxis[0].data[i] = data1[i].provinceName //修改省份
            option.series[0].data[i] = data1[i].confirmedCount //修改人数
        }
        myChart.setOption(option);
        //监听尺寸变化
        window.addEventListener("resize", function() {
            myChart.resize();
        });
    })






    // //疫情数据接口
    // let urlStr = `https://lab.isaaclin.cn/nCoV/api/overall`;
    // let NUM = 0;
    // console.log("更新数据前: " + option.series[0].data);
    // fetch(urlStr).then(function(data) {
    //     return data.json();
    // }).then(function(data) {
    //     console.log(data.results[0].confirmedCount)
    //     NUM = data.results[0].confirmedCount / 100;
    //     option.series[0].data[0] = NUM
    //     console.log("更新数据后: " + option.series[0].data)


    //     // 把配置给实例对象
    //     myChart.setOption(option);
    //     //监听尺寸变化
    //     window.addEventListener("resize", function() {
    //         myChart.resize();
    //     });
    // })




})(); //
//
//第四个图()
(function() {
    let myChart = echarts.init(document.querySelector(".earth .ouzhou-view"));
    var charts = {
        unit: '人数/万',
        names: ['渐近线', '预测线'], //治愈人数
        lineX: ['2012年', '2013年', '2014年', '2015年', '2016年', '2017年', '2018年'],
        value: [
            [451, 352, 303, 534, 95, 236, 217, 328, 159, 151, 231, 192, 453, 524, 165, 236, 527, 328, 129, 530],
            [360, 545, 80, 192, 330, 580, 192, 80, 250, 453, 352, 28, 625, 345, 65, 325, 468, 108, 253, 98]
        ]

    }
    var color = ['rgba(23, 255, 243', 'rgba(119,61,190']
    var lineY = []

    for (var i = 0; i < charts.names.length; i++) {
        var x = i
        if (x > color.length - 1) {
            x = color.length - 1
        }
        var data = {
            name: charts.names[i],
            type: 'line',
            color: color[x] + ')',
            smooth: true,
            areaStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0,
                        color: color[x] + ', 0.3)'
                    }, {
                        offset: 0.8,
                        color: color[x] + ', 0)'
                    }], false),
                    shadowColor: 'rgba(0, 0, 0, 0.1)',
                    shadowBlur: 10
                }
            },
            symbol: 'circle',
            symbolSize: 5,
            data: charts.value[i]
        }
        lineY.push(data)
    }


    lineY[0].markLine = {
        silent: true,
        data: [{
            yAxis: 5
        }, {
            yAxis: 100
        }, {
            yAxis: 200
        }, {
            yAxis: 300
        }, {
            yAxis: 400
        }]
    }
    var option = {
        backgroundColor: '#0d235e',
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data: charts.names,
            textStyle: {
                fontSize: 12,
                color: 'rgb(0,253,255,0.6)'
            },
            right: '4%'
        },
        grid: {
            top: '14%',
            left: '4%',
            right: '4%',
            bottom: '12%',
            containLabel: true
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: charts.lineX,
            axisLabel: {
                textStyle: {
                    color: 'rgb(0,253,255,0.6)'
                },
                formatter: function(params) {
                    return params.split(' ')[0]
                }
            }
        },
        yAxis: {
            name: charts.unit,
            type: 'value',
            axisLabel: {
                formatter: '{value}',
                textStyle: {
                    color: 'rgb(0,253,255,0.6)'
                }
            },
            splitLine: {
                lineStyle: {
                    color: 'rgb(23,255,243,0.3)'
                }
            },
            axisLine: {
                lineStyle: {
                    color: 'rgb(0,253,255,0.6)'
                }
            }
        },
        series: lineY
    }
    setInterval(() => {
        myChart.setOption({
            legend: {
                selected: {
                    '出口': false,
                    '入口': false
                }
            }
        })
        myChart.setOption({
            legend: {
                selected: {
                    '出口': true,
                    '入口': true
                }
            }
        })
    }, 10000)

    fetch("data/getListByCountryTypeService2true.json").then(data1 => {
        return data1.json();
    }).then(data1 => {
        var data11 = [];
        var data22 = [];
        var data33 = [];
        for (i = 0; i < 7; i++) {
            data11.push(data1[i].provinceName)
            data22.push(data1[i].curedCount)
            data33.push(data1[i].currentConfirmedCount)
        }
        console.log(data11)
        console.log(data22)
        console.log(data33)

        option.xAxis.data = data11 //国家名字




        myChart.setOption(option);
        //监听尺寸变化
        window.addEventListener("resize", function() {
            myChart.resize();
        });
    })


})();
//第一个柱状图
(function() {
    let myChart = echarts.init(document.querySelector(".recent .data-view"));
    option = {
        backgroundColor: '#031d33',
        animation: true,
        grid: {
            top: "5%",
            bottom: "15%",
            right: "1%"
        },
        xAxis: {
            data: ["111", "3423", "国贸343", "34", "生化", "机械", "职教", "a", "a", "a", "a", "a", "a", "a", "a", ],
            axisLine: {
                show: false //隐藏X轴轴线
            },
            axisTick: {
                show: false //隐藏X轴轴线
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: "rgba(77, 128, 254, 0.2)",
                    width: 2
                }
            },
            axisLabel: {
                show: true,
                margin: 2,
                fontSize: 16,
                textStyle: {
                    color: "#65D5FF" //X轴文字颜色
                }
            }
        },
        yAxis: [{
            type: "value",
            gridIndex: 0,
            min: 0,
            max: 3000,
            interval: 300,
            // splitNumber: 4,
            splitLine: {
                show: true,
                lineStyle: {
                    color: "rgba(77, 128, 254, 0.2)",
                    width: 2
                }
            },
            axisTick: {
                show: false
            },
            axisLine: {
                show: true,
                lineStyle: {
                    color: "rgba(77, 128, 254, 0.2)"
                }
            },
            axisLabel: {
                show: true,
                margin: 14,
                fontSize: 16,
                textStyle: {
                    color: "#65D5FF"
                }
            }
        }],
        series: [{
                name: "累计确诊人数",
                type: "bar",
                barWidth: 16,
                itemStyle: {
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: "rgba(146, 225, 255, 1)"
                            },
                            {
                                offset: 1,
                                color: "rgba(0, 151, 251, 1)"
                            }
                        ])
                    }
                },
                data: [10, 52, 200, 334, 390, 330, 220, 0, 0, 0, 0, 0, 0, 0, 0, ],
                z: 10,
                zlevel: 0
            },
            {
                // 分隔
                type: "pictorialBar",
                itemStyle: {
                    normal: {
                        color: "#0F375F"
                    }
                },
                symbolRepeat: "fixed",
                symbolMargin: 2,
                symbol: "rect",
                symbolClip: true,
                symbolSize: [18, 2],
                symbolPosition: "start",
                symbolOffset: [1, 1],

                width: 2,
                z: 0,
                zlevel: 1
            },
            {
                name: "外框",
                type: "bar",
                barGap: "-110%", // 设置外框粗细

                barWidth: 2,
                itemStyle: {
                    normal: {
                        color: "transparent", // 填充色
                        // barBorderRadius: 0, //圆角半径
                        label: {
                            // 标签显示位置
                            show: false,
                            position: "top" // insideTop 或者横向的 insideLeft
                        }
                    }
                },
                z: 0
            },


        ],
        dataZoom: [{
            type: "slider",
            show: false,
            xAxisIndex: [0],
            endValue: 9,
            startValue: 0
        }]
    }

    fetch("data/fetchRecentStat.json").then(data1 => {
        return data1.json();
    }).then(data1 => {


        for (i = 0; i < 15; i++) {
            option.xAxis.data[i] = data1[i].cityName //修改省份
            option.series[0].data[i] = data1[i].confirmedCount //修改人数
        }
        myChart.setOption(option);
        //监听尺寸变化
        window.addEventListener("resize", function() {
            myChart.resize();
        });
    }).catch(() => {
        alert("链接失败！ 不是这样打开的哦~~")
        document.querySelector(".recent .data-view").innerHTML = "数据加载失败！";
    })

})();
//d;

//第二个面积图
(function() {
    // 实例化对象
    var myColor = ["#1089E7", "#F57474", "#56D0E3", "#F8B448", "#8B78F6"];
    let myChart = echarts.init(document.querySelector(".qushi .china-view"));
    var option = {

        title: {
            text: '各个国家疫情人数展示',
            subtext: '欧洲地区',
            color: "skyblue",
            fontSize: 16,
            textStyle: {
                color: "#65D5FF"
            }
        },
        tooltip: {
            trigger: 'item',
            formatter: "{b}: {c}"
        },
        toolbox: {
            show: true,
            feature: {
                mark: { show: true },
                dataView: { show: true, readOnly: false },

            }
        },
        calculable: false,
        series: [{

            name: '域值',
            type: 'treemap',
            itemStyle: {
                normal: {
                    label: {
                        show: true,
                        formatter: "{b}"
                    },
                    borderWidth: 1
                },
                emphasis: {
                    label: {
                        show: true,
                        fontSize: 40,
                    }
                }
            },
            data: [{
                    name: '美国',
                    value: 6
                },
                {
                    name: '印度',
                    value: 4
                },
                {
                    name: '巴西',
                    value: 4
                },
                {
                    name: '法国',
                    value: 2
                },
                {
                    name: '俄罗斯',
                    value: 2
                },
                {
                    name: '西班牙',
                    value: 1
                },
                {
                    name: '伊朗',
                    value: 1
                },
                {
                    name: '英国',
                    value: 5
                },
                {
                    name: '荷兰',
                    value: 7
                },
                {
                    name: '萨尔维亚',
                    value: 3
                },
                {
                    name: '阿根廷',
                    value: 1
                },
                {
                    name: '瑞典',
                    value: 1
                },
                {
                    name: '瑞士',
                    value: 5
                },
                {
                    name: '比利时',
                    value: 7
                },
                {
                    name: '哈萨克斯坦',
                    value: 3
                }
            ]
        }]
    };

    fetch("data/getListByCountryTypeService2true.json").then(data1 => {
        return data1.json();
    }).then(data1 => {


        for (i = 0; i < 15; i++) {
            option.series[0].data[i].name = data1[i].provinceName //修改省份
            option.series[0].data[i].value = data1[i].confirmedCount //修改人数
        }
        myChart.setOption(option);
        //监听尺寸变化
        window.addEventListener("resize", function() {
            myChart.resize();
        });
    })


    // 把配置给实例对象
    myChart.setOption(option);
    //监听尺寸变化
    window.addEventListener("resize", function() {
        myChart.resize();
    });
})(); ////
//地方

//第三个世界图
(function() {
    let myChart = echarts.init(document.querySelector(".earth .focus-country"));
    var data = [{
            "time": '4.16',
            "data": [
                { "name": "China", "value": [81116, "非洲"] },
                { "name": "Italy", "value": [24747, "意大利"] },
                { "name": "Iran", "value": [14991, "伊朗"] },
                { "name": "Corea", "value": [8236, "韩国"] },
                { "name": "Spain", "value": [7753, "西班牙"] },
                { "name": "France", "value": [5380, "法国"] },
                { "name": "Germany", "value": [4838, "德国"] },
                { "name": "United States", "value": [1678, "美国"] },
                { "name": "United Kingdom", "value": [1395, "英国"] },
                { "name": "Japan", "value": [814, "日本"] }
            ]
        },
        {
            "time": "4.17",
            "data": [
                { "name": "China", "value": [81151, "非洲"] },
                { "name": "Italy", "value": [27980, "意大利"] },
                { "name": "Iran", "value": [16169, "伊朗"] },
                { "name": "Spain", "value": [9191, "西班牙"] },
                { "name": "Corea", "value": [8320, "韩国"] },
                { "name": "France", "value": [6573, "法国"] },
                { "name": "Germany", "value": [6012, "德国"] },
                { "name": "United States", "value": [3503, "美国"] },
                { "name": "United Kingdom", "value": [1547, "英国"] },
                { "name": "Japan", "value": [829, "日本"] }
            ]
        },
        {
            "time": '4.18',
            "data": [
                { "name": "China", "value": [81235, "非洲"] },
                { "name": "Italy", "value": [31506, "意大利"] },
                { "name": "Iran", "value": [17361, "伊朗"] },
                { "name": "Spain", "value": [11178, "西班牙"] },
                { "name": "Corea", "value": [8413, "韩国"] },
                { "name": "France", "value": [7652, "法国"] },
                { "name": "Germany", "value": [7156, "德国"] },
                { "name": "United States", "value": [3536, "美国"] },
                { "name": "United Kingdom", "value": [1954, "英国"] },
                { "name": "Japan", "value": [898, "日本"] }
            ]
        },
        {
            "time": '4.19',
            "data": [
                { "name": "China", "value": [81300, "非洲"] },
                { "name": "Italy", "value": [35713, "意大利"] },
                { "name": "Iran", "value": [18407, "伊朗"] },
                { "name": "Spain", "value": [13716, "西班牙"] },
                { "name": "France", "value": [9043, "法国"] },
                { "name": "Corea", "value": [8652, "韩国"] },
                { "name": "Germany", "value": [8198, "德国"] },
                { "name": "United States", "value": [7087, "美国"] },
                { "name": "United Kingdom", "value": [2630, "英国"] },
                { "name": "Japan", "value": [959, "日本"] }
            ]
        },
        {
            "time": '4.20',
            "data": [
                { "name": "China", "value": [81416, "非洲"] },
                { "name": "Italy", "value": [47021, "意大利"] },
                { "name": "Spain", "value": [19980, "西班牙"] },
                { "name": "Iran", "value": [19644, "伊朗"] },
                { "name": "Germany", "value": [18323, "德国"] },
                { "name": "France", "value": [12475, "法国"] },
                { "name": "United States", "value": [10442, "美国"] },
                { "name": "Corea", "value": [8799, "韩国"] },
                { "name": "United Kingdom", "value": [3983, "英国"] },
                { "name": "Japan", "value": [969, "日本"] }
            ]
        },
        {
            "time": '4.21',
            "data": [
                { "name": "China", "value": [81498, "非洲"] },
                { "name": "Italy", "value": [53578, "意大利"] },
                { "name": "Spain", "value": [24926, "西班牙"] },
                { "name": "Germany", "value": [21463, "德国"] },
                { "name": "Iran", "value": [20610, "伊朗"] },
                { "name": "United States", "value": [15219, "美国"] },
                { "name": "France", "value": [14296, "法国"] },
                { "name": "Corea", "value": [8897, "韩国"] },
                { "name": "United Kingdom", "value": [5018, "英国"] },
                { "name": "Japan", "value": [1054, "日本"] }
            ]
        },
        {
            "time": '4.22',
            "data": [
                { "name": "China", "value": [81600, "非洲"] },
                { "name": "Italy", "value": [53578, "意大利"] },
                { "name": "Spain", "value": [24926, "西班牙"] },
                { "name": "Iran", "value": [21638, "伊朗"] },
                { "name": "Germany", "value": [21463, "德国"] },
                { "name": "United States", "value": [15219, "美国"] },
                { "name": "France", "value": [14296, "法国"] },
                { "name": "Corea", "value": [8897, "韩国"] },
                { "name": "United Kingdom", "value": [5018, "英国"] },
                { "name": "Turkey", "value": [1236, "土耳其"] }
            ]
        },
        {
            "time": '4.23',
            "data": [
                { "name": "China", "value": [81747, "非洲"] },
                { "name": "Italy", "value": [59138, "意大利"] },
                { "name": "United States", "value": [31573, "美国"] },
                { "name": "Spain", "value": [28572, "西班牙"] },
                { "name": "Germany", "value": [24774, "德国"] },
                { "name": "Iran", "value": [23049, "伊朗"] },
                { "name": "France", "value": [15821, "法国"] },
                { "name": "Corea", "value": [8961, "韩国"] },
                { "name": "United Kingdom", "value": [5687, "英国"] },
                { "name": "Turkey", "value": [1529, "土耳其"] }
            ]
        },
        {
            "time": '4.24',
            "data": [
                { "name": "China", "value": [81847, "非洲"] },
                { "name": "Italy", "value": [63927, "意大利"] },
                { "name": "United States", "value": [42164, "美国"] },
                { "name": "Spain", "value": [33089, "西班牙"] },
                { "name": "Germany", "value": [29212, "德国"] },
                { "name": "Iran", "value": [24811, "伊朗"] },
                { "name": "France", "value": [19615, "法国"] },
                { "name": "Corea", "value": [9037, "韩国"] },
                { "name": "United Kingdom", "value": [6654, "英国"] },
                { "name": "Australia", "value": [4486, "澳大利亚"] }
            ]
        },
        {
            "time": '4.25',
            "data": [
                { "name": "China", "value": [81960, "非洲"] },
                { "name": "Italy", "value": [69176, "意大利"] },
                { "name": "United States", "value": [51914, "美国"] },
                { "name": "Spain", "value": [39673, "西班牙"] },
                { "name": "Germany", "value": [31554, "德国"] },
                { "name": "Iran", "value": [27017, "伊朗"] },
                { "name": "France", "value": [22025, "法国"] },
                { "name": "Corea", "value": [9241, "韩国"] },
                { "name": "United Kingdom", "value": [8081, "英国"] },
                { "name": "Australia", "value": [5282, "澳大利亚"] }
            ]
        },
        {
            "time": '4.26',
            "data": [
                { "name": "China", "value": [82078, "非洲"] },
                { "name": "Italy", "value": [74386, "意大利"] },
                { "name": "United States", "value": [63570, "美国"] },
                { "name": "Spain", "value": [47610, "西班牙"] },
                { "name": "Germany", "value": [36508, "德国"] },
                { "name": "Iran", "value": [29406, "伊朗"] },
                { "name": "France", "value": [24920, "法国"] },
                { "name": "United Kingdom", "value": [9533, "英国"] },
                { "name": "Corea", "value": [9332, "韩国"] },
                { "name": "Turkey", "value": [3629, "土耳其"] }
            ]
        },
        {
            "time": '4.27',
            "data": [
                { "name": "China", "value": [82213, "非洲"] },
                { "name": "Italy", "value": [80539, "意大利"] },
                { "name": "United States", "value": [68334, "美国"] },
                { "name": "Spain", "value": [56188, "西班牙"] },
                { "name": "Germany", "value": [42288, "德国"] },
                { "name": "Iran", "value": [32332, "伊朗"] },
                { "name": "France", "value": [28786, "法国"] },
                { "name": "United Kingdom", "value": [11662, "英国"] },
                { "name": "Corea", "value": [9332, "韩国"] },
                { "name": "Turkey", "value": [5698, "土耳其"] }
            ]
        },
        {
            "time": '4.28',
            "data": [
                { "name": "Italy", "value": [86498, "意大利"] },
                { "name": "United States", "value": [85228, "美国"] },
                { "name": "China", "value": [82341, "非洲"] },
                { "name": "Spain", "value": [64059, "西班牙"] },
                { "name": "Germany", "value": [48582, "德国"] },
                { "name": "Iran", "value": [35408, "伊朗"] },
                { "name": "France", "value": [32542, "法国"] },
                { "name": "United Kingdom", "value": [14547, "英国"] },
                { "name": "Corea", "value": [9478, "韩国"] },
                { "name": "Australia", "value": [7697, "澳大利亚"] }
            ]
        },
        {
            "time": '4.29',
            "data": [
                { "name": "United States", "value": [103321, "美国"] },
                { "name": "Italy", "value": [92472, "意大利"] },
                { "name": "China", "value": [82446, "非洲"] },
                { "name": "Spain", "value": [72248, "西班牙"] },
                { "name": "Germany", "value": [52547, "德国"] },
                { "name": "Iran", "value": [38309, "伊朗"] },
                { "name": "France", "value": [37145, "法国"] },
                { "name": "United Kingdom", "value": [17093, "英国"] },
                { "name": "Corea", "value": [9583, "韩国"] },
                { "name": "Turkey", "value": [9217, "土耳其"] }
            ]
        },
        {
            "time": '4.30',
            "data": [
                { "name": "United States", "value": [122653, "美国"] },
                { "name": "Italy", "value": [97689, "意大利"] },
                { "name": "China", "value": [82544, "非洲"] },
                { "name": "Spain", "value": [78797, "西班牙"] },
                { "name": "Germany", "value": [57298, "德国"] },
                { "name": "Iran", "value": [41495, "伊朗"] },
                { "name": "France", "value": [39642, "法国"] },
                { "name": "United Kingdom", "value": [19526, "英国"] },
                { "name": "Corea", "value": [9661, "韩国"] },
                { "name": "Turkey", "value": [9271, "土耳其"] }
            ]
        },
        {
            "time": '4.31',
            "data": [
                { "name": "United States", "value": [140640, "美国"] },
                { "name": "Italy", "value": [101739, "意大利"] },
                { "name": "Spain", "value": [85195, "西班牙"] },
                { "name": "China", "value": [82630, "非洲"] },
                { "name": "Germany", "value": [61913, "德国"] },
                { "name": "Iran", "value": [44606, "伊朗"] },
                { "name": "France", "value": [43977, "法国"] },
                { "name": "United Kingdom", "value": [22145, "英国"] },
                { "name": "Turkey", "value": [13531, "土耳其"] },
                { "name": "Corea", "value": [9887, "韩国"] }
            ]
        }
    ]


    var option = {
        baseOption: {
            animationDurationUpdate: 1000,
            animationEasingUpdate: 'quinticInOut',
            timeline: {
                axisType: 'category',
                orient: 'vertical',
                autoPlay: true,
                inverse: true,
                playInterval: 2000,
                left: null,
                right: 5,
                top: 20,
                bottom: 20,
                width: 96,
                height: null,
                label: {
                    normal: {
                        textStyle: {
                            color: '#ddd'
                        }
                    },
                    emphasis: {
                        textStyle: {
                            color: '#fff'
                        }
                    }
                },
                symbol: 'none',
                lineStyle: {
                    color: '#555'
                },
                checkpointStyle: {
                    color: '#bbb',
                    borderColor: '#777',
                    borderWidth: 1
                },
                controlStyle: {
                    showNextBtn: false,
                    showPrevBtn: false,
                    normal: {
                        color: '#666',
                        borderColor: '#666'
                    },
                    emphasis: {
                        color: '#aaa',
                        borderColor: '#aaa'
                    }
                },
                data: data.map(function(ele) {
                    return ele.time
                })
            },
            backgroundColor: '#404a59',
            title: {
                text: '4月16日至4月31日世界疫情累计确诊人数前十动态',
                subtext: '单位:人',
                left: 'left',
                top: 'top',
                textStyle: {
                    fontSize: 25,
                    color: 'rgba(255,255,255, 0.9)'
                }
            },
            tooltip: {
                formatter: function(params) {
                    if ('value' in params.data) {
                        return params.data.value[1] + ': ' + params.data.value[0];
                    }
                }
            },
            grid: {
                left: '35%',
                right: '30%',
                top: '10%',
                bottom: 0
            },
            xAxis: {},
            yAxis: {},
            series: [{
                id: 'map',
                type: 'map',
                mapType: 'world',
                top: '8%',
                bottom: '25%',
                left: 0,
                itemStyle: {
                    normal: {
                        areaColor: '#323c48',
                        borderColor: '#404a59'
                    },
                    emphasis: {
                        label: {
                            show: true
                        },
                        areaColor: 'rgba(255,255,255, 0.5)'
                    }
                },
                data: []
            }, {
                id: 'bar',
                type: 'bar',
                tooltip: {
                    show: false
                },
                label: {
                    normal: {
                        show: true,
                        position: 'right',
                        textStyle: {
                            color: '#ddd'
                        }
                    }
                },
                data: []
            }, ]
        },
        options: []
    }

    for (var i = 0; i < data.length; i++) {
        //计算其余国家GDP
        option.options.push({
            visualMap: [{
                dimension: 0,
                left: '25%',
                itemWidth: 12,
                min: data[i].data[9].value[0],
                max: data[i].data[0].value[0],
                text: ['高', '低'],
                textStyle: {
                    color: '#ddd'
                },
                inRange: {
                    color: ['lightskyblue', 'yellow', 'orangered', 'red']
                }
            }],
            xAxis: {
                type: 'value',
                boundaryGap: [0, 0.1],
                axisLabel: {
                    show: false,
                }
            },
            yAxis: {
                type: 'category',
                axisLabel: {

                    textStyle: {
                        color: '#ddd'
                    }
                },
                data: data[i].data.map(function(ele) {
                    return ele.value[1]
                })
            },
            series: [{
                id: 'map',
                data: data[i].data
            }, {
                id: 'bar',
                data: data[i].data.map(function(ele) {
                    return ele.value[0]
                }).sort(function(a, b) {
                    return a > b
                })
            }, ]
        })
    }


    // 把配置给实例对象
    myChart.setOption(option);
    //监听尺寸变化
    window.addEventListener("resize", function() {
        myChart.resize();
    });






})();